 

package com.zdkj.subway.stm.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zdkj.common.core.util.R;
import com.zdkj.common.log.annotation.SysLog;
import com.zdkj.subway.stm.entity.SwStTicketPettyAddDetails;
import com.zdkj.subway.stm.service.SwStTicketPettyAddDetailsService;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;


/**
 * 车站配票详情
 *
 * @author songtuo
 * @date 2020-07-09 14:14:41
 */
@RestController
@AllArgsConstructor
@RequestMapping("/swstticketpettyadddetails" )
@Api(value = "swstticketpettyadddetails", tags = "车站配票详情管理")
public class SwStTicketPettyAddDetailsController {

    private final  SwStTicketPettyAddDetailsService swStTicketPettyAddDetailsService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param swStTicketPettyAddDetails 车站配票详情
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page" )
    public R getSwStTicketPettyAddDetailsPage(Page page, SwStTicketPettyAddDetails swStTicketPettyAddDetails) {
        return R.ok(swStTicketPettyAddDetailsService.page(page, Wrappers.query(swStTicketPettyAddDetails)));
    }


    /**
     * 通过id查询车站配票详情
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}" )
    public R getById(@PathVariable("id" ) Integer id) {
        return R.ok(swStTicketPettyAddDetailsService.getById(id));
    }

    /**
     * 新增车站配票详情
     * @param swStTicketPettyAddDetails 车站配票详情
     * @return R
     */
    @ApiOperation(value = "新增车站配票详情", notes = "新增车站配票详情")
    //@SysLog("新增车站配票详情" )
    @PostMapping
    @PreAuthorize("@pms.hasPermission('generator_swstticketpettyadddetails_add')" )
    public R save(@RequestBody SwStTicketPettyAddDetails swStTicketPettyAddDetails) {
        return R.ok(swStTicketPettyAddDetailsService.save(swStTicketPettyAddDetails));
    }

    /**
     * 修改车站配票详情
     * @param swStTicketPettyAddDetails 车站配票详情
     * @return R
     */
    @ApiOperation(value = "修改车站配票详情", notes = "修改车站配票详情")
    //@SysLog("修改车站配票详情" )
    @PutMapping
    @PreAuthorize("@pms.hasPermission('generator_swstticketpettyadddetails_edit')" )
    public R updateById(@RequestBody SwStTicketPettyAddDetails swStTicketPettyAddDetails) {
        return R.ok(swStTicketPettyAddDetailsService.updateById(swStTicketPettyAddDetails));
    }

    /**
     * 通过id删除车站配票详情
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除车站配票详情", notes = "通过id删除车站配票详情")
    //@SysLog("通过id删除车站配票详情" )
    @DeleteMapping("/{id}" )
    @PreAuthorize("@pms.hasPermission('generator_swstticketpettyadddetails_del')" )
    public R removeById(@PathVariable Integer id) {
        return R.ok(swStTicketPettyAddDetailsService.removeById(id));
    }

}
